﻿using System;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace SpyTxT
{
    [Serializable]
    public class City
    {
        [XmlAttributeAttribute("name")]
        public string name{get;set;}

        [XmlAttributeAttribute("id")]
        public string id{get;set;}

        public override string ToString()
        {
            return name;
        }

    }
    [Serializable]
    public class AreaCityList
    {
        [XmlAttributeAttribute("name")]
        public string name{get;set;}

        [XmlAttributeAttribute("areaid")]
        public string areaid { get; set; }

        [XmlElement("city", Type = typeof(City))]
        public List<City> citylist{get;set;}

      
    }
    [Serializable]
    public class AreaListCity
    {
        [XmlElement("area", Type = typeof(AreaCityList))]
        public List<AreaCityList> list;
    }

    [Serializable]
    [XmlRoot("mylist")]
    public class rootmylist
    {
        [XmlElement("areaList")]
        public AreaListCity rootlist;

        public string findcityIdbyName(string name)
        {
            foreach (AreaCityList a in rootlist.list)
            {
                foreach (City c in a.citylist)
                {
                    if (c.name == name)
                    {
                        return c.id;
                    }
                }
            }

            return null;
        }

    }
    public class AreaListTree : ObservableCollection<AreaCityList>
    {
        public AreaListTree()
        {

        }
    }

}
